package com.yanqu.road.server.cmd.systemgroup.newmonopolymkt.office;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.newmonopolymkt.NewMonopolyMarketProto;
import com.yanqu.road.server.cmd.CrossAppointCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.systemgroup.newmonopolymkt.CrossNewMonopolyMarketGroup;
import com.yanqu.road.server.manager.systemgroup.newmonopolymkt.CrossNewMonopolyMarketMgr;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.C_CROSS_NEW_MONOPOLY_MARKET_OFFICE_ENTER, desc = "进入大宋榷署 大厅")
public class CrossMonopolyMarketOfficeEnterCmd extends CrossAppointCommand {

    private long userId;
    private int page;
    private long time;
    private boolean isGetNotice;


    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        NewMonopolyMarketProto.NewMonopolyMarketEnterOfficeReqMsg req = NewMonopolyMarketProto.NewMonopolyMarketEnterOfficeReqMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        page = req.getPage();
        time = req.getTime();
        isGetNotice = req.getIsGetNotice();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossNewMonopolyMarketGroup monopolyMarket = CrossNewMonopolyMarketMgr.getMarket(groupId);
        if(monopolyMarket != null){
            MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(Protocol.U_NEW_MONOPOLY_MARKET_OFFICE_ENTER,
                 monopolyMarket.getMarketOffice().enter(serverId, userId, page, time, isGetNotice)));
        }else {

        }
    }

    @Override
    public void sendData() {

    }
}
